<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html">

<h:body>
	<h:form>
		<p:dataTable id="table" var="orderDraft"
			value="#{orderDraftList.orderDrafts}" paginator="false"
			widgetVar="orderDraftsTable">


			<p:column sortBy="#{orderDraft.orderDraftId}" style="width:10%">
				<f:facet name="header">
					<h:outputText value="Order Id:" />
				</f:facet>
				<h:outputText value="#{orderDraft.orderDraftId}" />
			</p:column>

			<p:column sortBy="#{orderDraft.orderName}" style="width:30%">
				<f:facet name="header">
					<h:outputText value="Order Name" />
				</f:facet>
				<h:outputText value="#{orderDraft.orderName}" />
			</p:column>

			<p:column sortBy="#{orderDraft.plateArticle.articleId}"
				style="width:20%">
				<f:facet name="header">
					<h:outputText value="Article" />
				</f:facet>
				<h:outputText value="#{orderDraft.plateArticle.articleId}" />
			</p:column>

			<p:column sortBy="#{timerBean.formatDate(orderDraft.orderDraftDate)}"
				style="width:20%">
				<f:facet name="header">
					<h:outputText value="Draft date" />
				</f:facet>
				<h:outputText
					value="#{timerBean.formatDate(orderDraft.orderDraftDate)}" />
			</p:column>

			<p:column>
				<p:commandButton value="Make order"
					action="#{orderAdd.makeOrderFromDraft(orderDraft.orderDraftId)}"
					icon="ui-icon-pencil" ajax="false" />
				<p:commandButton id="deleteDraft" icon="ui-icon-trash"
					onclick="confirmation.show()" type="button" />


				<p:confirmDialog id="confirmDeleteDraft"
					message="Are you sure you want to delete your order draft?"
					header="Deleting order draft" severity="alert" widgetVar="confirmation">
					<p:commandButton value="Yew" id="confirmDelete" onclick="confirmation.hide()"
						action="#{orderDraftList.removeDraft(orderDraft.orderDraftId)}"
						ajax="false" />
					<p:commandButton id="declineCancel" value="No"
						onclick="confirmation.hide()" type="button" />

				</p:confirmDialog>
			</p:column>
		</p:dataTable>
	</h:form>

</h:body>
</html>